1 Imports System.Data.OleDb
2 Imports System.DateTime
3 Imports System.Math
4 Public Class Form1
5 Inherits System.Windows.Forms.Form
6 Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=CLInventory.accdb; Persist Security Info=False"
7 Dim MyCommand
8 Dim e As Exception
9 Dim MyCommand2
10 Dim MyReader As OleDbDataReader
11 Dim MyReader2 As OleDbDataReader
12 Dim dbset As New DataSet
13 Dim dataA
14
15 Dim currentDate As Date
16 Dim UserStatus As String
17 Dim passTry As Integer = 0
18
19 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
20 Me.BringToFront()
21 Me.Focus()
22 End Sub
23 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
24 Application.Exit()
25 End Sub
26 Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
27 Dim strChar As String
28 strChar = e.KeyChar
29
30 Select Case strChar
31 Case ChrW(System.Windows.Forms.Keys.Enter)
32 If TextBox1.Text = "" Then
33 MsgBox("Please Enter a User Name!", MsgBoxStyle.Information, "LIS VERSION 1.00")
34 Else
35 If TextBox1.Text <> "" Then
36 TextBox2.Focus()
37 End If
38 End If
39 Case Else
40 End Select
41 End Sub
42 Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
43 Dim strChar As String
44 strChar = e.KeyChar
45
46 Select Case strChar
47 Case ChrW(System.Windows.Forms.Keys.Enter)
48 If TextBox1.Text = "" Then
49 MsgBox("Please Enter Your Password!", MsgBoxStyle.Information, "LIS VERSION 1.00")
50 Else
51 If TextBox1.Text <> "" Then
52 Button1.Focus()
53 End If
54 End If
55 Case Else
56 End Select
57 End Sub
58 Function verifyUser() As Boolean
59 Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
60 OleDbConn.Open()
61
62 Dim MyOledbCommand As OleDbCommand = New OleDbCommand()
63
64 MyCommand = New OleDbCommand("SELECT * FROM Login WHERE UserID = '" & TextBox1.Text & "'", OleDbConn)
65 MyReader = MyCommand.ExecuteReader()
66 While MyReader.Read
67 TextBox3.Text = MyReader("pass")
68 End While
69 OleDbConn.Close()
70 MyReader.Close()
71 MyCommand.dispose()
72 If TextBox2.Text = TextBox3.Text Then
73 Return True
74 Else
75 If TextBox2.Text <> TextBox3.Text Then
76 Return False
77 End If
78 End If
79 End Function
80 Function getStatus() As String
81 Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
82 OleDbConn.Open()
83
84 Dim MyOledbCommand As OleDbCommand = New OleDbCommand()
85 MyCommand = New OleDbCommand("SELECT * FROM Login WHERE UserID = '" & TextBox1.Text & "'", OleDbConn)
86 MyReader = MyCommand.ExecuteReader()
87 While MyReader.Read
88 UserStatus = MyReader("Status")
89 End While
90 OleDbConn.Close()
91 MyReader.Close()
92 MyCommand.dispose()
93 Return UserStatus
94 End Function
95 Sub display_MsgBox(ByVal myMsg As String)
96 MsgBox(myMsg, MsgBoxStyle.Information, "LIS Version 1.00")
97 End Sub
98
99
100 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
101 Dim main_frm = New Main_Form
102
103
104 If verifyUser() = True And getStatus() = "ok" And passTry < 3 Then
105 main_frm.Show()
106 Else
107 If verifyUser() = False And passTry < 3 And getStatus() = "ok" Then
108 passTry = passTry + 1
109 display_MsgBox("Sayop imo Password!")
110 Else
111 If passTry = 3 Then
112 passTry = 0
113 display_MsgBox("Your User Has Been Locked After Three Un-Authorised Attempts! Please Contact Your System Administrator")
114 Else
115 If getStatus() <> "ok" Then
116 display_MsgBox("Please Try Again")
117 End If
118 End If
119 End If
120 End If
121 End Sub
122
123
124 End Class